<template>
  <view class="content" style="background: #857fd9; padding: 20rpx; margin: 20rpx;">
    <view class="title">子组件B</view>
    <view class="b-box">
      CompA组件传进来的值:
      <text class="intent-text-box" style="background: #fff; padding: 5rpx;">{{ result }}</text>
    </view>
    <view class="b-box" style="margin: 10rpx;">
      <text>回传值: </text>
      <input type="text" v-model="callBackValue" style="color: deeppink;border: 1px solid #ccc; padding:5rpx;"
	   placeholder="请输入回传值"/>
      <button @click="sendOutside()" size="mini">回传</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      result: '',
      callBackValue: '' 
    }
  },
  created() {
   
    uni.$on('getIntent', (val) => {
		console.warn('----ComB----接收A的值----->'+val)
      this.result = val
    })
  },
  methods: {
    
    sendOutside() {
		console.warn('当前输入框的值:',this.callBackValue);
      console.warn('----ComB----sendOutside----->' + this.callBackValue)
      this.$emit('callBackFun', this.callBackValue)
    }
  }
}
</script>

<style>
.title {
  font-size: 30rpx;
  font-weight: bold;
  margin-bottom: 20rpx;
}
.b-box {
  margin: 10rpx 0;
}
</style>